#include <iostream>
#include <fstream>
#include <string>
#include "Batu.h"

int main()
{
    ifstream fin;
    string tags;
    int start_page, end_page, page_id;
    char page_id_c[5];

    fin.open("data.txt");
    fin >> tags >> start_page >> end_page;
    fin.close();

    while(start_page <= end_page)
    {
        page_id = (start_page - 1) * 28;
        sprintf(page_id_c, "%d", page_id);
        Batu test(tags, page_id_c);
        cout << "Acquiring source page..." << endl;
        test.GetSourcePageContent();
        cout << "Analysing source page..." << endl;
        if(!test.GetTargetPageURLAndPreviewURL())
        {
            cout << "There's noting but chicken here!" << endl;
            break;
        }
        cout << "Acquiring target page... This may take a few minutes." << endl;
        test.GetTargetPageContent();
        cout << "Analysing picture url..." << endl;
        test.GetTargetURL();
        cout << "Downloading picture..." << endl;
        test.GetPic();
        
        start_page++;
    }

    return 0;
}